﻿using System.Runtime.Serialization;

namespace Order
{
    [DataContract]
    public class Customer : System.ICloneable
    {
        [DataMember]
        [System.ComponentModel.DataAnnotations.Key]
        public int ID { get; init; }
        [DataMember]
        public string Name { get; set; }
        public Customer()
        {
            ID = base.GetHashCode();
        }
        public override string ToString()
        {
            return "Customer name: " + Name;
        }
        public override bool Equals(object obj)
        {
            if (obj is not Customer c) return false;
            return Name == c.Name;
        }

        public override int GetHashCode()
        {
            return Name?.GetHashCode() ?? 0;
        }

        public object Clone()
        {
            return new Customer()
            {
                ID = ID,
                Name = Name
            };
        }
    }
}
